package com.app.Network;

import android.util.Log;

import com.app.Activity.frmMatKetNoiActivity;
import com.app.Tree.BoardView;
import com.app.Tree.BoardViewTN;

public class WriteXMLThread extends Thread{
	private static boolean isRunning=false;	
	public BoardView board ;
	private BoardViewTN boardTN ;
	
	private WriteXMLThread(){
		super();
	}
	public WriteXMLThread(BoardView view){
		this.board = view;
	}
	public WriteXMLThread(BoardViewTN view){
		this.boardTN = view;
	}
	
	public static void setRunning(boolean isRunning) {
		WriteXMLThread.isRunning = isRunning;
	}
	@Override
	public void run() {
//		isRunning=true;
		while (isRunning) {
			if(!frmMatKetNoiActivity.isShowed){
				try {					
					if(board.isActive){
						Log.d("Phu", "WriteXMLThread 1 ");
						board.writeXML(board.treePath);
					}else{
						Log.d("Phu", "WriteXMLThread 2 ");
						boardTN.writeXML(boardTN.treePath);
					}					
					sleep(5000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
		}
	}
}
